<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

class CreateProjectsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('projects', function (Blueprint $table) {
            $table->increments('id');
            $table->string("project_name", 50)->comment('项目名称');
            $table->integer("project_type_id")->comment('项目类型id');
            $table->string("project_cover", 150)->comment('项目封面');
            $table->string("project_url", 100)->comment('项目地址');
            $table->string("project_github_url", 150)->comment('项目github地址');
            $table->string("project_desc", 150)->comment('项目描述');
            $table->tinyInteger("is_show")->default(0)->comment("是否启用 0:不显示 1:显示");
            $table->softDeletes()->comment('删除时间');
            $table->timestamp('created_at')->useCurrent()->comment('创建时间');
            $table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'))->comment('更新时间');
            $table->index('project_type_id', 'index_project_type_id');
        });
        DB::statement("ALTER TABLE ". env("DB_PREFIX") ."projects comment '友链表'");//表注释
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('projects');
    }
}
